#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# ======================================================
# @File:      : test1
# @Author     : forward_huan
# @Date       : 2024/11/16 17:03
# @Desc       :
# ======================================================
from typing import List


class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        data = [(num, index) for index, num in enumerate(nums)]
        data.sort(key=lambda item: item[0])
        left, right = 0, len(data) - 1
        while left < right:
            if data[left][0] + data[right][0] == target:
                return [data[left][1], data[right][1]]
            if data[left][0] + data[right][0] < target:
                left += 1
            else:
                right -= 1
        return []


print(Solution().twoSum(nums=[2, 7, 11, 15], target=9))
print(Solution().twoSum(nums=[3, 2, 4], target=6))
print(Solution().twoSum(nums=[3, 3], target=6))
